package com.jmebananas.renderer.pass;

import com.jme.renderer.Camera;
import com.jme.renderer.Renderer;

/**
 * CameraRenderPass
 * 
 * @author Glenn Powell
 *
 */
public class CameraRenderPass extends AdvancedRenderPass {

	private static final long serialVersionUID = 1L;
	
	
	private Camera camera;
	
	
	public CameraRenderPass(Camera camera) {
		this(camera, DEFAULT_RENDERPASS_INDEX);
	}

	public CameraRenderPass(Camera camera, int index) {
		super(index);
		
		this.camera = camera;
	}
	
	public void doRender(Renderer renderer) {
		Camera oldCamera = renderer.getCamera();
		camera.update();
		renderer.setCamera(camera);
		
		super.doRender(renderer);

		oldCamera.update();
		renderer.setCamera(oldCamera);
	}

}
